{include file="header/index" /}

<div class="newContentBox">
    <div class="fixedFather">
            <div class="fix">
                    添加配置
                    <!-- <span class="newNotice"><span class="newtext">*</span>为必填项</span> -->
                    <div class="newFixBtnBox">
                            <button type="button" class="newBtnDefault newBtnGray" onclick="returnBack(this)"> <i class="fa fa-mail-reply"></i>返回</button>
                    </div>
            </div>
    </div>
    <form class="layui-form newListPart layui-none-top">
         <div class="layui-one-list">
            <div class="layui-form-item cover_layui_f_i">
                <label class="layui-form-label cover_layui_f_l"> 配置标识：</label>
                <div class="layui-input-block cover_layui_i_b">
                    <input id="name" type="text"  name="name" required  lay-verify="required"   autocomplete="off" class="layui-input">
                        <div class="tishow"><i class="fa fa-info-circle"></i> 用于config函数调用，只能使用英文且不能重复</div>
                 </div>  
            </div>
        </div>
        <div class="layui-one-list">
            <div class="layui-form-item cover_layui_f_i">
                <label class="layui-form-label cover_layui_f_l"> 配置标题：</label>
                <div class="layui-input-block cover_layui_i_b">
                    <input id="title" type="text" name="title" required  lay-verify="required"  autocomplete="off" class="layui-input">
                        <div class="tishow"><i class="fa fa-info-circle"></i> 用于后台显示的配置标题</div>
                 </div>  
            </div>
        </div>
        <div class="layui-one-list">
            <div class="layui-form-item cover_layui_f_i">
                <label class="layui-form-label cover_layui_f_l"> 配置类型：</label>
                <div class="layui-input-block cover_layui_i_b">
                    <select id="type" name="type" lay-verify="" lay-search>
                        <option value="0">==请选择==</option>
                            {volist name="Think.config.config_type_list" id="type"}
                                <option value="{$key}">{$type}</option>
                            {/volist}
                    </select>
                    <div class="tishow"><i class="fa fa-info-circle"></i> （系统会根据不同类型解析配置值）</div>
                 </div>  
            </div>
        </div>
        <div class="layui-one-list">
            <div class="layui-form-item cover_layui_f_i">
                <label class="layui-form-label cover_layui_f_l"> 配置分组：</label>
                <div class="layui-input-block cover_layui_i_b">
                    <select id="group" name="group" lay-verify="" lay-search>
                        <option value="0">==请选择==</option>
                            {volist name="Think.config.config_group_list" id="group"}
                                <option value="{$key}">{$group}</option>
                            {/volist}
                    </select>
                        <div class="tishow"><i class="fa fa-info-circle"></i> （配置分组 用于批量设置 不分组则不会显示在系统设置中）</div>
                 </div>  
            </div>
        </div>
        <div class="layui-one-list">
            <div class="layui-form-item cover_layui_f_i">
                <label class="layui-form-label cover_layui_f_l"> 配置值：</label>
                <div class="layui-input-block cover_layui_i_b">
                    <input id="value" type="text" name="value" required  lay-verify="required"  autocomplete="off" class="layui-input">
                        <div class="tishow"><i class="fa fa-info-circle"></i> 用于config函数调用显示的值</div>
                 </div>  
            </div>
        </div>
         <div class="layui-one-list">
            <div class="layui-form-item cover_layui_f_i">
                <label class="layui-form-label cover_layui_f_l"> 配置项：</label>
                <div class="layui-input-block cover_layui_i_b">
                    <textarea type="text" rows="5" name="extra" id="extra" class="layui-textarea layui-input"></textarea>
                    <div class="tishow"><i class="fa fa-info-circle"></i> 如果是枚举型 需要配置该项</div>
                 </div>  
            </div>
        </div>
        <div class="layui-one-list">
            <div class="layui-form-item cover_layui_f_i">
                <label class="layui-form-label cover_layui_f_l"> 配置描述：</label>
                <div class="layui-input-block cover_layui_i_b">
                    <textarea type="text" rows="5" name="remark" id="remark"  class="layui-textarea layui-input"></textarea>
                    <div class="tishow"><i class="fa fa-info-circle"></i>  配置详细说明</div>
                 </div>  
            </div>
        </div>
        <div class="layui-one-list">
            <div class="layui-form-item cover_layui_f_i">
                <label class="layui-form-label cover_layui_f_l"> 排序：</label>
                <div class="layui-input-block cover_layui_i_b">
                    <input id="sort" type="text"  value="0" name="sort"  class="layui-input">
                    <div class="tishow"><i class="fa fa-info-circle"></i> 用于显示的顺序</div>
                 </div>  
            </div>
        </div>
        <div class="layui-one-list">
            <div class="layui-form-item cover_layui_f_i">
                <label class="layui-form-label cover_layui_f_l"> 状&nbsp;态：</label>
                <div class="layui-input-block cover_layui_i_b">
                    <input type="checkbox" name='status' value="1"  lay-skin="primary" checked  title="默认开启">
                 </div>  
            </div>
        </div>
         <div class="layui-one-list">
                <div class="layui-form-item ">
                    <div class="layui-input-block cover_layui_i_b">
                        <button class="layui-btn newBtnDefault newBtnPrimary" lay-submit lay-filter="formDemo">保存</button>
                        <button type="reset" class="layui-btn newBtnDefault">重置</button>
                    </div>
                </div>
         </div>
        
    </form>
</div>
<script >
    var layer = layui.layer,
        element = layui.element,
        laydate = layui.laydate,
        laypage = layui.laypage,
        form = layui.form,
        upload = layui.upload,
        layedit = layui.layedit;
        form.render();
    //提交表单
    var flag = false;
      form.on('submit(formDemo)', function(data){

        if(flag){
        return false;
        }
        flag = true;
        delete data.field.file //true
        $.post("{:url('add_config')}",data.field,function(e){
          if(e.code == 1){
            top.layer.msg(e.msg, {
              icon: 1,
              time: 2000
            },function(){
              top.layer.close();
              //history.go(-1); 
               window.location.href = "{:url('index')}";
            });
          }else{
            top.layer.msg(e.msg, {
              icon: 0,
              time: 2000
            });
          }
          flag = false;
        },'json');
        return false;
      });

</script>
